﻿using Microsoft.Extensions.Configuration;
using MiniFox.Configurations;

namespace DataTransfer.Core.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    public class ExcelExportSetting
    {
        const string NAME = "name";
        const string TEMPLATE = "template";
        const string EXCEL_FORMAT = "excelFormat";
        const string MAX_ROW_COUNT_PER_SHEET = "maxRowCountPerSheet";
        const string DATA_LOADER_TYPE = "dataLoaderType";
        const string SHEETS = "sheets";
        const string MODULES = "modules";

        internal const int MAX_ROW_COUNT = 65536;

        /// <summary>
        /// 名称
        /// </summary>
        [ConfigurationKeyName(NAME)]
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// excel模板文件
        /// </summary>
        [ConfigurationKeyName(TEMPLATE)]
        public string Template
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName(DATA_LOADER_TYPE)]
        public string DataLoaderTypeName
        {
            get;
            set;
        }

        ///// <summary>
        ///// 
        ///// </summary>
        //public Type DataLoaderType
        //{
        //    get
        //    {
        //        var typeName = this.DataLoaderTypeName;
        //        if (string.IsNullOrEmpty(typeName))
        //        {
        //            return typeof(DefaultDataLoader);
        //        }
        //        Type loaderType = Type.GetType(this.DataLoaderTypeName, true, true);
        //        return loaderType;
        //    }
        //}

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName(EXCEL_FORMAT)]
        public string ExcelFormat
        {
            get;
            set;
        } = "XLS";

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName(MAX_ROW_COUNT_PER_SHEET)]
        public int MaxRowCountPerSheet
        {
            get;
            set;
        } = MAX_ROW_COUNT;

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName(SHEETS)]
        public ExcelExportSheetSettingCollection Sheets
        {
            get;
            set;
        } = [];

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName(MODULES)]
        public ProviderSettingsCollection Modules
        {
            get;
            set;
        } = [];
    }
}
